package com.sjgtw.cloud.file.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.minio.MinioClient;

/**
 * 
 * <p>Title: Minio 参数配置信息</p>
 * <p>Description: </p>
 * @author Admin
 * @date 2021-4-12
 */
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig
{
	/**
	 * 服务地址
	 */
	private String url;

	private String readUrl;

	/**
	 * 用户名
	 */
	private String accessKey;

	/**
	 * 密码
	 */
	private String secretKey;

	/**
	 * 存储桶名称
	 */
	private String bucketName;

	public String getReadUrl() {
		return readUrl;
	}

	public void setReadUrl(String readUrl) {
		this.readUrl = readUrl;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getAccessKey() {
		return accessKey;
	}

	public void setAccessKey(String accessKey) {
		this.accessKey = accessKey;
	}

	public String getSecretKey() {
		return secretKey;
	}

	public void setSecretKey(String secretKey) {
		this.secretKey = secretKey;
	}

	public String getBucketName() {
		return bucketName;
	}

	public void setBucketName(String bucketName) {
		this.bucketName = bucketName;
	}

	@Bean
	public MinioClient getMinioClient() {
		return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
	}
}
